import Vue from 'vue';

/**
 * 表格翻页自动回到顶部的指令
 *
 * v-tableTop="currentPage"
 *
 * private currentPage: number = 1;
 */
Vue.directive('tableTop', {
    update: function(el, binding, vnode) {
        if (binding.value === binding.oldValue) {
            return;
        }
        const ele = el.querySelector('.el-table__body-wrapper');
        if (ele) {
            ele.scrollTop = 0;
        }
    },
});
